package spring.cloud.chapter2;


//import io.github.yedaxia.apidocs.Docs;
//import io.github.yedaxia.apidocs.DocsConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.hateoas.client.LinkDiscoverer;
import org.springframework.hateoas.client.LinkDiscoverers;
import org.springframework.hateoas.mediatype.collectionjson.CollectionJsonLinkDiscoverer;
import org.springframework.plugin.core.SimplePluginRegistry;
import org.springframework.web.client.RestTemplate;

import java.util.ArrayList;
import java.util.List;


@SpringBootApplication(scanBasePackages = "spring.cloud.chapter2.*")
public class Chapter2Application {


    public static void main(String[] args) {

//        DocsConfig config = new DocsConfig();
//        config.setProjectPath("I:\\springcloud2020\\chapter2"); // 项目根目录
//        config.setProjectName("chapter2"); // 项目名称
//        config.setApiVersion("V1.0");       // 声明该API的版本
//        config.setDocsPath("I:\\springcloud2020\\chapter2\\JApiDocs"); // 生成API 文档所在目录
//        config.setAutoGenerate(Boolean.TRUE);  // 配置自动生成
//        //导出markdown
////        config.addPlugin(new MarkdownDocPlugin());
//        Docs.buildHtmlDocs(config); // 执行生成文档

        SpringApplication.run(Chapter2Application.class, args);
    }

    //初始化 restTemplate
    @Bean("restTemplate")
    public RestTemplate initRestTemplate(){
        return new RestTemplate();
    }


    //解决 spring-hateoas 包和 springfox-swagger2 包的spring-core-Plugin 冲突
    @Bean
    public LinkDiscoverers discovers() {

        List<LinkDiscoverer> plugins = new ArrayList<>();
        plugins.add(new CollectionJsonLinkDiscoverer());
        return new LinkDiscoverers(SimplePluginRegistry.create(plugins));

    }

}
